package cn.bdqn.util;


import cn.bdqn.model.ConstUtil;
import cn.bdqn.sys.model.Enterprise;
import cn.bdqn.sys.model.User;

import javax.servlet.http.HttpSession;

/**
 * @author Li Ruihuan
 * @create 2019-06-24 12:18
 */
public class SessionUtil {
    public static User getUser(HttpSession session){
        return (User) session.getAttribute(ConstUtil.USER);
    }
    public static Enterprise getEnterprise(HttpSession session){
        return (Enterprise) session.getAttribute(ConstUtil.ENTERPRISE);
    }
    public static Integer getUserId(HttpSession session){
        return  getUser(session).getUid();
    }
    public static Integer getEId(HttpSession session){
        return  getUser(session).getEid();
    }

    public static void addUser(HttpSession session, User user){
        session.setAttribute(ConstUtil.USER,user);
    }
    public static void addEnterprise(HttpSession session, Enterprise enterprise){
        session.setAttribute(ConstUtil.ENTERPRISE,enterprise);
    }
}
